package com.wzc.hc.service.impl;

import cn.dev33.satoken.stp.StpInterface;
import com.wzc.hc.service.MenuService;
import com.wzc.hc.service.RoleService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * 自定义权限验证接口扩展
 */
@Component    // 保证此类被springboot扫描，完成sa-token的自定义权限验证扩展 
public class StpInterfaceImpl implements StpInterface {
    @Resource
    private RoleService roleService;
    @Resource
    private MenuService menuService;

    /**
     * 返回一个账号所拥有的权限码集合
     */
    @Override
    public List<String> getPermissionList(Object loginId, String loginKey) {
        return new ArrayList<>();
        //        return menuService.getMenuListByUserId(loginId.toString()).stream().map(Menu::getMenuName).toList();
    }

    /**
     * 返回一个账号所拥有的角色标识集合 (权限与角色可分开校验)
     */
    @Override
    public List<String> getRoleList(Object loginId, String loginKey) {
        return new ArrayList<>();
        //        return roleService.getRoleListByUserId(loginId.toString()).stream().map(Role::getRoleName).toList();
    }
}
